package com.alibaba.cloud.base.business.order.controller;

import com.alibaba.cloud.base.business.order.domain.BasOrder;
import com.alibaba.cloud.base.business.order.service.BasOrderService;
import com.alibaba.framework.aop.log.LogWrite;
import com.alibaba.framework.domain.ResponseWrapper;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Tag(name = "基础模块")
@RestController
@RequestMapping("/order")
public class BasOrderController {

    private static final Logger LOGGER = LoggerFactory.getLogger(BasOrderController.class);

    @Resource
    private BasOrderService basOrderService;

    @LogWrite(value = "查询医嘱项目列表")
    @GetMapping("/getAll")
    public ResponseWrapper getAll() {

        List<BasOrder> basOrderList = basOrderService.getAll();
        return ResponseWrapper.Success(basOrderList);
    }

    @LogWrite(value = "根据医嘱类型查询医嘱项目")
    @GetMapping("/getOrderListByType")
    public ResponseWrapper getOrderListByType(@RequestParam("orderType") String orderType) {

        List<BasOrder> basOrderList = basOrderService.getOrderListByType(orderType);
        return ResponseWrapper.Success(basOrderList);
    }

    @LogWrite(value = "新增医嘱项目")
    @PostMapping("/save")
    public ResponseWrapper save(@RequestBody BasOrder basOrder) {

        basOrderService.save(basOrder);
        return ResponseWrapper.Success();
    }
}
